package com.chixing.day01_syntax;

import java.nio.charset.StandardCharsets;

/**
 * 文档注释：用于说明 该类的作用
 * 标识符的命名规则：
 *   1.只能 字母、数字、下划线_、美元$ 组成
 *
 * package包名：字母全部小写、一般是网站或组织的逆序
 * class 类名：单词首字母必须全部大写，不允许数字开头，upperCamleCase
 */
public class SyntaxDemo {
    //主函数 main函数：程序运行的入口
    public static void main(String[] args){
        byte b1 = 123;
        byte b2 = -128;

        short s9 = 4665;
        //byte b3 = 233 //233是 int 类型
        int age = 20;
        int proCount = 10;


        //18666335665 int类型
        //18666335665L long类型
        long telno = 18666335665L;

        float stuHeight = 1.78f;
        float proPrice = 9.9f;

        double d1 = 99.9;

        // character : char
        char c1 = 'a';
        char c2 = '%';
        char c3 = ' ';
        char c4 = '\'';
        char c5 = '\"';
        System.out.println(c4);

        boolean bo1 = false;
        boolean bo2 = 4>3;

        boolean isExist = false;
        boolean hasNext = false;

        boolean flag;

        //向上转换：高字节 = 低字节的值
        //数据类型转换 convert，cast
        byte b4 = 12;
        int i1 = b4;

        long l1 = 7788;//7788 int 类型 4字节，int类型转换成long类型
        long l2 = 7788L;//7788 long 类型 8字节

        double d3 = 99.9f;

        // 强制类型转换：byte b5 = (byte) int值，可能会造成精度缺失
        int i2 = 129;
        byte b5 = (byte) i2;//强制类型转换
        System.out.println(b5);//


        float f3 = (float) 455467866.669954446;
        System.out.println(f3);

        // char <----> int 直接相互转换
        //a 97  A 65
        System.out.println((int)'a');//97
        System.out.println((char)69);//E

        //输出a-z
        char ch1 = 'a';
        ch1++;
        System.out.println(ch1);

        for (char c ='a';c<='z';c++){
            System.out.println(c);
        }
        //输出A-Z
        for (char c7 ='A';c7<='Z';c7++){
            System.out.println(c7);
        }
        /*for (int i=97;i<123;i++){
            System.out.println((char)i);
        }*/

        //he hi
        System.out.println("a - b = "+('a'-'b'));

        int x = 30;
        int y = 20;

        if (x>y)
            System.out.println("x>y");
        else
            System.out.println("x<=y");

        if (x>y)
            System.out.println("x>y");
        System.out.println("x<=y");

        short s7 = 1;
        s7 = (short) (s7 + 1);
        short s1 = 1;
        s1 +=1;




        /*
            ‘你’ --- 几个字节？
                        UTF_8占3个字节
                        ISO_8859_1占3个字节

            char:[你

        */
        char cc ='你';//一个字符

        String ss = "abc";
        String sss = "你";
        System.out.println(sss.toCharArray().length);//1
        System.out.println("一个字符 ‘你’所占的字节数： "+sss.getBytes(StandardCharsets.UTF_8).length);//3

        byte[] by1 = {63};
        String result1 = new String(by1,StandardCharsets.ISO_8859_1);
        System.out.println("result1="+result1);
    }
}
